package com.itqf.ipmsys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itqf.ipmsys.dto.PoliceSituationDto;
import com.itqf.ipmsys.entity.PoliceSituation;
import com.itqf.ipmsys.mapper.PoliceSituationMapper;
import com.itqf.ipmsys.service.PoliceSituationService;
import com.itqf.ipmsys.vo.PoliceSituationListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 警情表 服务实现类
 * </p>
 *
 * @author corn
 * @since 2021-09-22
 */
@Service
public class PoliceSituationServiceImpl extends ServiceImpl<PoliceSituationMapper, PoliceSituation> implements PoliceSituationService {


    @Autowired
    private PoliceSituationMapper policeSituationMapper;

    /**
     * @param policeSituationDto
     * @return
     */
    @Override
    public Object findAllPoliceSituationService(PoliceSituationDto policeSituationDto) {
        Map<String, Object> data = new HashMap<>();
        int index = (policeSituationDto.getPage() - 1) * policeSituationDto.getPagesize();
        List<PoliceSituationListVO> list = policeSituationMapper.selectPoliceSituationList(policeSituationDto, index);
        int total = policeSituationMapper.selectPoliceSituationTotal(policeSituationDto);
        data.put("policesituations",list);
        data.put("total",total);
        return data;
    }

    /**
     * 查询单个
     *
     * @return
     */
    @Override
    public Object findOnePoliceSituationService(int id){

        PoliceSituation policeSituation = policeSituationMapper.selectById(id);

        return policeSituation;
    }
}
